草庐IT

javascript - X 秒后执行 JavaScript

全部标签

javascript - 谷歌javascript登录api : no offline access

我正在尝试为服务器端应用程序实现Google登录,如Google文档所示:GoogleSign-Inforserver-sideapps,但同意窗口从不要求离线访问。选择用户后,它会关闭并调用登录处理函数。因此,当我获得一次性代码并将其发送到服务器时,我无法将其交换为刷新token,只能交换访问token和IDtoken。这是我的客户端代码:在HTML文件中:Javascript代码:varauth2;functioninit(){gapi.load('auth2',function(){auth2=gapi.auth2.init({client_id:'.apps.googleuse

javascript - 用于异步事件的 jQuery

我有一个html按钮需要异步触发3个事件。如果我有这个:$('#id').click(function(e){func1();});$('#id').click(function(e){func2();});$('#id').click(function(e){func3();});我能得到并发吗?或者如果一个功能需要很长时间,下一个功能会被阻止吗?Javascript如何处理这种顺序调用?谢谢, 最佳答案 “一个功能需要很长时间,下一个功能会被阻止”-您与我们共享的代码将以这种方式运行。您需要显式实现异步事件,因为@Zakaria

javascript - 使用 startAt 和 endAt 的 Firebase 结果范围

我尝试从我的Firebase数据中获取前100个结果,然后是接下来的100个,然后是接下来的100个等等。我尝试了多种方法。版本1ref.child('products').orderByChild('domain').startAt(0).endAt(100).once('value').then(function(snapshot){});版本2ref.child('products').orderByChild('domain').startAt(0).limitToFirst(100).once('value').then(function(snapshot){});版本3re

javascript - MS Edge 无法检测 <use> SVG 元素的委托(delegate)事件?

我想我在MSEdge中发现了一个令人不安的错误,它会影响动态创建的SVG元素。Edge似乎能够检测到直接绑定(bind)的事件,即$('.use').on('click',...),但是委托(delegate)事件$('body').on('click','use',...)被忽略。它最容易用JSFiddle来说明(在Chrome中测试,绑定(bind)都有效,而在Edge中委托(delegate)绑定(bind)不起作用):https://jsfiddle.net/Lr0arahb/有没有人对此问题有任何见解,并且知道可能的解决方法?最重要的是,我正在寻找一个我们仍然可以使用的解决方

javascript - typeof something 返回对象而不是数组

x是一个数组。我做console.log(x)我有['value']但是当我检查类型为console.log(typeofx)的x时,它说它是一个对象。为什么? 最佳答案 数组是JS中的对象。如果你需要为数组测试一个变量:if(x.constructor===Array)console.log('itsanarray'); 关于javascript-typeofsomething返回对象而不是数组,我们在StackOverflow上找到一个类似的问题: htt

javascript - 使用 Protractor 获取按钮上的禁用属性不起作用

我试图在一个按钮上获取禁用属性,它应该被“禁用”,但我似乎没有得到值。Angular和Protractor的新手!当我检查页面时,这是我得到的显示已禁用按钮的HTML,就像它在页面上一样:Save下面的Protractor测试返回'Expectednulltoequaldisabled'varbtnSave=element(by.css('.primary'));expect(btnSave.isPresent()).toBeTruthy();varattr=element(by.css('.primary')).getAttribute('disabled');expect(attr

javascript - 在拦截器中使用 `$mdToast` 触发循环依赖

问题:如何在拦截器中使用$mdToast而不触发错误?设置:拦截器定义:(function(){'usestrict';angular.module('app.components.http-errors-interceptors').factory('HttpError500Interceptor',HttpError500Interceptor);/*@ngInject*/functionHttpError500Interceptor($q,$mdToast,$filter){varinterceptor={};interceptor.responseError=responseE

javascript - SVG numberOfItems 属性不起作用

我们的网站在最新更新后突然停止在Chrome上运行(只是chrome)...给出的错误是UncaughtTypeError:Cannotreadproperty'numberOfItems'ofundefined这是使用numberOfItems属性的地方://Absolutizeandparsepathtoarray,parse:function(array){/*ifit'salreadyisapatharray,noneedtoparseit*/if(arrayinstanceofSVG.PathArray)returnarray.valueOf()/*prepareforpar

javascript - 在 Node.js 中模拟嵌套模块?

我有这些文件:文件1.jsvarmod1=require('mod1');mod1.someFunction()...文件2.jsvarFile1=require('./File1');现在在为File2编写单元测试时,是否可以模拟mod1,这样我就不会调用mod1.someFunction()? 最佳答案 我通常使用mockery模块,如下所示:lib/file1.jsvarmod1=require('./mod1');mod1.someFunction();lib/file2.jsvarfile1=require('./file

javascript - 使用 http.get node.js 的 promise

我正在做nodeschool练习,Thisproblemisthesameasthepreviousproblem(HTTPCOLLECT)inthatyouneedtousehttp.get().However,thistimeyouwillbeprovidedwiththreeURLsasthefirstthreecommand-linearguments.YoumustcollectthecompletecontentprovidedtoyoubyeachoftheURLsandprintittotheconsole(stdout).Youdon'tneedtoprintoutt